package com.example.design.行为型设计模式.策略模式;

// ShoppingCart.java
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

// 上下文（上下文类）
public class ShoppingCart {
    private final List<String> items;
    @Setter
    private PaymentStrategy paymentStrategy;

    public ShoppingCart() {
        items = new ArrayList<>();
    }

    public void addItem(String item) {
        items.add(item);
    }

    public void checkout(int amount) {
        System.out.println("Items in cart: " + items);
        paymentStrategy.pay(amount);
    }
}
